<!--
 * @Author: ckk
 * @Date: 2022-08-27 14:30:36
 * @LastEditors: ckk
 * @LastEditTime: 2022-10-24 13:46:51
 * @Description: 渲染目录
-->
<template>
  <yj-mob-popup
    v-model="show"
    class="cata-dialog"
    position="bottom"
    @close="onClose"
    @click-overlay="onClose"
    :style="{ height: '60%' }"
  >
    <div class="list-content">
      <div class="header">
        <div class="title">请选择学习的章节</div>
        <div class="right" @click="onSwitch">
          <span class="title">切换版本</span>
          <yj-mob-image width="18" height="18" :src="sel" />
        </div>
      </div>
    </div>

    <Catalogue ref="Catalogue" :currentId="currentId" @onSelect="onSelect"></Catalogue>
  </yj-mob-popup>
</template>

<script>
import { Popup, Tree, image } from 'yj-mob-ui';
export default {
  components: {
    [Popup.name]: Popup,
    [Tree.name]: Tree,
    [image.name]: image,
    Catalogue: () => import('../Catalogue')
  },
  props: {
    cataShow: {
      type: Boolean,
      default: false
    },
    list: {
      type: Object
    },
    activeName: {
      type: String
    },
    currentId: {
      type: String
    }
  },
  data () {
    return {
      show: false,
      treeData: {},
      sel: require('../../assets/images/lession/icon-indicate@2x.png')
    };
  },
  watch: {
    cataShow (newValue) {
      this.show = newValue;
    }
  },
  methods: {
    onClose () {
      this.show = false;
      this.$emit('onClose');
    },
    onSwitch () {
      this.$emit('onSwitch');
    },
    onSelect (item) {
      console.log(item, 'item');
      this.show = false;
      this.$emit('onSelect', item);
    }
  }
};
</script>

<style lang="scss">
.cata-dialog {
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0px -3px 6px 0px rgba(0, 0, 0, 0.05);
  padding: 30px 5px;
  box-sizing: border-box;
  overflow: hidden;
  padding-bottom: 0;
  .les-cata {
    height: calc(60vh - 80px);;
    margin-top: 20px;
  }
  .list-content {
    position: relative;
    height: 20px;
    .header {
      background: white;
      padding: 0 15px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: absolute;
      width: calc(100vw - 30px);
      left: 0;
      top: -16px;
      z-index: 2500;
    }
    .title {
      font-size: 16px;
      font-family: PingFang SC, PingFang SC-Regular, sans-serif;
      font-weight: 400;
      text-align: left;
      color: rgba(0, 0, 0, 0.85);
      line-height: 26px;
    }
    .right {
      display: flex;
      align-items: center;
    }
  }
}
</style>
